home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / vacate.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  88 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: vacate.c,v 1.4 1996/08/13 13:56:09 digulla Exp $
  4.     $Log: vacate.c,v $
  5.     Revision 1.4  1996/08/13 13:56:09  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:21  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "exec_intern.h"
  17. #include "semaphores.h"
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22.     #include <exec/semaphores.h>
  23.     #include <clib/exec_protos.h>
  24.  
  25.     __AROS_LH2(void, Vacate,
  26.  
  27. /*  SYNOPSIS */
  28.     __AROS_LHA(struct SignalSemaphore  *, sigSem, A0),
  29.     __AROS_LHA(struct SemaphoreMessage *, bidMsg, A1),
  30.  
  31. /*  LOCATION */
  32.     struct ExecBase *, SysBase, 91, Exec)
  33.  
  34. /*  FUNCTION
  35.     Release a lock obtained with Procure. This will even work if the
  36.     message is not yet replied - the request will be cancelled and the
  37.     message replied. In any case the ssm_Semaphore field will be set to
  38.     NULL.
  39.  
  40.     INPUTS
  41.     sigSem - Pointer to semaphore structure.
  42.     bidMsg - Pointer to struct SemaphoreMessage.
  43.  
  44.     RESULT
  45.  
  46.     NOTES
  47.  
  48.     EXAMPLE
  49.  
  50.     BUGS
  51.  
  52.     SEE ALSO
  53.     Procure()
  54.  
  55.     INTERNALS
  56.  
  57.     HISTORY
  58.     29-10-95    digulla automatically created from
  59.                 exec_lib.fd and clib/exec_protos.h
  60.  
  61. *****************************************************************************/
  62. {
  63.     __AROS_FUNC_INIT
  64.  
  65.     /* Arbitrate for the semaphore structure */
  66.     Forbid();
  67.  
  68.     /* Check if the message is still posted. */
  69.     if(bidMsg->ssm_Message.mn_Node.ln_Type==NT_MESSAGE)
  70.     {
  71.     /* Yes. Remove it from the semaphore's waiting queue. */
  72.     Remove(&bidMsg->ssm_Message.mn_Node);
  73.  
  74.     /* And reply the message. */
  75.     ReplyMsg(&bidMsg->ssm_Message);
  76.     }else
  77.     /* The semaphore is already locked. Release the lock. */
  78.     ReleaseSemaphore(sigSem);
  79.  
  80.     /* Clear the semaphore field. */
  81.     bidMsg->ssm_Semaphore=NULL;
  82.  
  83.     /* All done. */
  84.     Permit();
  85.     __AROS_FUNC_EXIT
  86. } /* Vacate */
  87.  
  88.